<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>恩联商品管理</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
<#include "../template/include/assign.ftl">
<#include "../template/include/source.ftl">
<#include "../template/template_listPage.ftl">
    <link href="${web_static}/admin/css/list.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .page {
            float: right;
            padding-top: 15px;
            margin-right: 15px;
        }
    </style>


    <script type="text/javascript">
        $(document).ready(function () {
            var $validateErrorContainer = $("#validateErrorContainer");
            var $validateErrorLabelContainer = $("#validateErrorContainer ul");
            var $validateForm = $("#inputForm");
            var $tab = $("#tab");
            // Tab效果
            $tab.tabs(".tabContent", {
                tabs:"input"
            });

            // 表单验证
            $validateForm.validate({
                errorContainer:$validateErrorContainer,
                errorLabelContainer:$validateErrorLabelContainer,
                wrapper:"li",
                errorClass:"validateError",
                ignoreTitle:true,
                rules:{
                    "priceRatio":{
                        required:true
                    }
                },
                messages:{
                    "priceRatio":{
                        required:"请输入价格利率,只能输入数字!!!"
                    }
                },
                submitHandler:function (form) {
                    //$(form).find(":submit").attr("disabled", true);
                    form.submit();
                }
            });

            $('#searchButton').click(
                    function () {
                        $('#currentPage_listForm').val('1');
                    }
            );

            $('#productState').val('<#if enLinkQuery??>${(enLinkQuery.productState)!}</#if>');
            $('#productType').val('<#if enLinkQuery??>${(enLinkQuery.productType)!}</#if>');

        <#if actionErrors?? && (actionErrors?size > 0)>
            $.dialog({type:"warn", content:"<#list errorMessages as list>${list}<br></#list>",
                modal:true, autoCloseTime:3000});
        </#if>

        });

        function editProduct(productId) {
            var proId = $('#productId').val();
            var productName = $('#productName').val();
            var productState = $('#productState').val();
            var productType = $('#productType').val();
            var url = "${web_base}/game/en_link!toEdit.htm?productId=" + productId;
            if (proId != null && proId != '') {
                url = url + "&proId=" + proId;
            }
            if (productName != null && productName != '') {
                url = url + "&productName=" + productName;
            }
            if (productState != null && productState != '') {
                url = url + "&productState=" + productState;
            }
            if (productType != null && productType != '') {
                url = url + "&productType=" + productType;
            }
            document.forms[2].action = encodeURI(url);
            document.forms[2].submit();
        }

    </script>
</head>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>恩联商品管理&nbsp;<span class="pageInfo"></span></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <div class="operateBar">
        <label>对商品进行批量操作：</label><input type="button" class="addButton" onclick="location.href='${web_base}/game/en_link!batchOnline.htm'"  value="批量上架" />
        <input type="button" class="addButton" onclick="location.href='${web_base}/game/en_link!batchOffline.htm'"  value="批量下架" />
        说明：对商品供应表中此供应商的商品进行批量上下架.
    </div>
    <form id="inputForm" class="validate" action="${web_base}/game/en_link!audit.htm" method="post">
        <div class="operateBar">
            <label>请输入价格利率：</label>
            <input type="text" name="priceRatio" value="" onkeyup="this.value=this.value.replace(/\D/g,'')"
                   onafterpaste="this.value=this.value.replace(/\D/g,'')"/>‰
            <input type="hidden" name="supplierId" value="20121003">
            <input type="submit" class="addButton" value="批量审核"/>
        </div>
    </form>

    <form method="post" class="validate" action="${web_base}/game/en_link!importProductFile.htm" enctype="multipart/form-data">
        <div class="operateBar">
            <label>批量导入数据：</label>&nbsp;&nbsp;&nbsp;
        <#--<input type="text" name="filePath" id="f1" />-->
        <#--<input type="button" value="浏览" onClick="f2.click();"/>-->
        <#--<input type="file" name="excel" id="f2" style="display: none;" onchange="document.getElementById('f1').value=this.value"/>-->
            <input type="file" name="productExcel"/>
            <input type="submit" name="submit" value="导入文件数据"/>
            <input type="button" onclick="location.href='${web_base}/game/en_link!add.htm'"
                   value="添加单条产品信息"/>
        </div>
    </form>


<@pageList page=(page!) id="listForm" action="${web_base}/game/en_link!list.htm" query="enLinkQuery" isEmpty=true>
    <div class="operateBar">

        <label>查找：</label>
        产品编号：<input type="text" id="productId" name="enLinkQuery.productId"
                    value="<#if enLinkQuery??>${(enLinkQuery.productId)!}</#if>"/>
        产品名称：<input type="text" id="productName" name="enLinkQuery.productName"
                    value="<#if enLinkQuery??>${(enLinkQuery.productName)!}</#if>"/>
        产品状态：<select name="enLinkQuery.productState" id="productState">
        <option value="1">
            上架
        </option>
        <option value="0">
            下架
        </option>
    </select>
        充值方式：
        <select name="enLinkQuery.productType" id="productType">
            <option value="" selected="selected">请选择...</option>
            <option value="2">
                直充
            </option>
            <option value="1">
                卡充
            </option>
        </select>
        <input type="submit" id="searchButton" class="searchButton" value=""/>
    </div>
    <table class="listTable">
        <tr>
            <th>
                <span class="sort" name="productId">产品编号</span>
            </th>
            <th>
                <span class="sort" name="productName">产品名称</span>
            </th>
            <th>
                <span class="sort" name="productInPrice">产品进价(元)</span>
            </th>
            <th>
                <span class="sort" name="productParvalue">产品面值(元)</span>
            </th>
            <th>
                <span class="sort" name="productType">充值方式</span>
            </th>
            <th>
                <span class="sort" name="productState">产品状态</span>
            </th>
            <th>
                <span class="sort" name="isAudit">审核状态</span>
            </th>
            <th>
                <span class="sort" name="importTime">录入时间</span>
            </th>
        <th width="80">操&nbsp;作
        <th/>
        </tr>

        <#if page?? && page.list?? && (page.list?size gt 0)>
            <#list page.list as obj>
                <tr>
                    <td>
                    ${(obj.productId)!}
                    </td>
                    <td>
                        <#if obj.productName?? && obj.productName?length gt 25>
                        <#--//截取输出文字的长度-->
                        ${obj.productName?substring(0,25)}...
                        <#else>
                        ${(obj.productName)!}
                        </#if>
                    </td>
                    <td>
                    ${(obj.productInPrice)!}
                    </td>
                    <td>
                    ${(obj.productParvalue)!}
                    </td>
                    <td>
                        <#if obj.productType?? && obj.productType=="2">
                            直充
                        <#elseif obj.productType?? && obj.productType=="1">
                            卡充
                        </#if>
                    </td>
                    <td>
                        <#if obj.productState?? && obj.productState=="1">
                            上架
                        <#elseif obj.productState?? && obj.productState=="0">
                            下架
                        </#if>
                    </td>
                    <td>
                        <#if obj.isAudit?? && obj.isAudit=="1">
                            已审核
                        <#elseif obj.isAudit?? && obj.isAudit=="0">
                            未审核
                        </#if>
                    </td>

                    <td>
                    ${(obj.importTime)!}
                    </td>
                <td width="80">
                    <span class="spanLink" onclick="editProduct('${(obj.productId)!}');" title="编辑">[编辑]</span>
                    <#--<a href="${web_base}/game/enLinkQuery!detail.htm?productId=${(obj.productId)!}" title="详情">[详情]</a>-->
                </td>
                </tr>
            </#list>
        </#if>
    </table>

    <#if page?? && page.list?? && (page.list?size <= 0)>
        <div class="noRecord">
            没有找到任何记录!
        </div>
    </#if>
</@pageList>
</div>

</body>
</html>